package com.example.liangwenli;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class SecondActivity extends AppCompatActivity {

    private EditText et_city;
    private TextView tv_query;
    private RecyclerView rv_result;
    private Button btn_page1;
    private Button btn_page2;
    private Button btn_page3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        //实例化控件
        et_city=findViewById(R.id.et_city);
        tv_query=findViewById(R.id.tv_query);
        rv_result=findViewById(R.id.rv_result);
        btn_page1=findViewById(R.id.btn_page1);
        btn_page2=findViewById(R.id.btn_page2);
        btn_page3=findViewById(R.id.btn_page3);
        //初始化数据
        ArrayList<String[]> list=new ArrayList<>();
        list.add(new String[]{"27℃~32℃，阴转雷阵雨 ","09日(星期三)"});
        list.add(new String[]{"27℃~33℃，雷阵雨 ","10日(星期四)"});
        list.add(new String[]{"28℃~33℃，雷阵雨转多云 ","11日(星期五)"});
        list.add(new String[]{"28℃~33℃，多云","12日(星期六)"});
        list.add(new String[]{"28℃~33℃，多云 ","13日(星期日)"});
        list.add(new String[]{"27℃~33℃，多云转雷阵雨 ","14日(星期一)"});
        list.add(new String[]{"26℃~31℃，雷阵雨转小于","15日(星期二)"});
        MainAdapter mainAdapter=new MainAdapter(list);
        rv_result.setLayoutManager(new LinearLayoutManager(this));
        rv_result.setAdapter(mainAdapter);
        et_city.setText("北海");
        //初始化事件
        btn_page1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //进入界面1
                startActivity(new Intent(SecondActivity.this,MainActivity.class));
                //关闭当前界面
                finish();
            }
        });
        btn_page2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(SecondActivity.this,"当前为界面2喔!",Toast.LENGTH_SHORT).show();
            }
        });
        btn_page3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //进入界面3
                startActivity(new Intent(SecondActivity.this,ThirdActivity.class));
                //关闭当前界面
                finish();
            }
        });
    }
}
